# coding=utf-8
import time
from typing import List, Optional
from smartpi import base_driver

# 触碰传感器读取
# port: 连接P端口 (0-7)
# 正常返回：触碰状态 (1:触碰, 0:未触碰)
# 读取错误：返回None
def get_value(port:bytes) -> Optional[bytes]:
    read_sw_str=[0xA0, 0x03, 0x01, 0xBE]
    read_sw_str[0]=0XA0+port   
    response = base_driver.single_operate_sensor(read_sw_str,0)
    if response == None:
        return None
    else:
        return response[4]